package com.bachongLightNovel.audit.controller;

import com.bachongLightNovel.audit.service.AuditNovelService;
import com.bachongLightNovel.model.dto.audit.AuditNovelDto;
import com.bachongLightNovel.model.vo.audit.AuditNovelVo;
import com.bachongLightNovel.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author vermouth
 */

@RestController
@RequestMapping("api/audit/audit-novel")
@Slf4j
public class AuditNovelController {

    @Autowired
    private AuditNovelService auditNovelService;

    /**
     * 获取需要审核的小说列表
     * @param :
     * @return Result
     * @author vermouth
     */
    @GetMapping("get-audits")
    public Result getAuditList(@RequestHeader(name = "Token") String token){
        log.info("获取需要审核的小说列表");
        List<AuditNovelVo> voList=auditNovelService.getAuditList(token);
        return Result.success(voList);
    }

    /**
     * 设置小说审核状态
     * @param dto:
     * @return Result
     * @author vermouth
     */
    @PutMapping("set-status")
    public Result setAuditStatus(@RequestBody AuditNovelDto dto){
        log.info("设置小说审核状态:{}",dto);
        auditNovelService.setAuditStatus(dto);
        return Result.success();
    }
}
